﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Order.ascx.cs" Inherits="PayrollHR.Administration.Modules.OrderControl" %>
<%@ Register Src="ToolTipLabelControl.ascx" TagName="ToolTipLabelControl" TagPrefix="uc1" %>
<%@ Register Src="DatePicker.ascx" TagName="DatePicker" TagPrefix="uc2" %>
<%@ Register Src="ConfirmationBox.ascx" TagName="ConfirmationBox" TagPrefix="uc3" %>
<script type="text/javascript">
    $(window).bind('load', function () {
        var cbHeader = $(".cbHeader input");
        var cbRowItem = $(".cbRowItem input");
        cbHeader.bind("click", function () {
            cbRowItem.each(function () { this.checked = cbHeader[0].checked; })
        });
        cbRowItem.bind("click", function () { if ($(this).checked == false) cbHeader[0].checked = false; });
    });
    function ClearText() {
        document.getElementById('<%=txtDistributor.ClientID%>').value = '';
    };
    function ClearTextWarehouse() {
        document.getElementById('<%=txtCustomerName.ClientID%>').value = '';
    };
</script>
<ajaxToolkit:TabContainer runat="server" ID="OrderTabs" ActiveTabIndex="0">
    <ajaxToolkit:TabPanel runat="server" ID="pnlOrderInfo" HeaderText="<% $PayrollResources:Admin.Order.OrderInput %>">
        <ContentTemplate>
            <div class="section-header">
                <div class="title">
                    <img src="Common/ico-sales.png" alt="<%=GetLocaleResourceString("Admin.Orders.Title")%>" />
                    <%=GetLocaleResourceString("Admin.Orders.Title")%>
                </div>
                <div class="options">
                    <asp:Button ID="SearchButton" runat="server" Text="<%$ PayrollResources:Admin.Orders.SearchButton %>"
                        CssClass="adminButtonBlue" OnClick="SearchButton_Click" ToolTip="<%$ PayrollResources:Admin.Orders.SearchButton.Tooltip %>" />
                    <asp:Button runat="server" Text="Delete"
                    CssClass="adminButtonBlue" ID="btnDelete" OnClick="btnDelete_Click" 
                    ToolTip="Delete Order" />
                <uc3:ConfirmationBox ID="cbDelete" runat="server" TargetControlID="btnDelete"
                    YesText="<% $PayrollResources:Admin.Common.Yes %>" NoText="<% $PayrollResources:Admin.Common.No %>"
                    ConfirmText="<% $PayrollResources:Admin.Common.AreYouSure %>" />
                    <input type="button" onclick="location.href = 'OrderAdd.aspx'" value="<%=GetLocaleResourceString("Admin.Order.AddNew")%>"
                    id="btnAddNew" class="adminButtonBlue" title="<%=GetLocaleResourceString("Admin.Order.AddNew")%>" />
                </div>
            </div>
            <div style="border: 1px solid #2F00FF; border-radius: 15px;">
                <table class="adminContent">
                    <tr>
                        <td class="adminTitle">
                            <uc1:ToolTipLabelControl ID="lblStartDate" runat="server" Text="<%$ PayrollResources:Admin.Order.StartDate.Text %>"
                                ToolTip="<%$ PayrollResources:Admin.Order.StartDate.ToolTip %>" ToolTipImage="~/Administration/Common/ico-help.gif" />
                        </td>
                        <td class="adminData">
                            <uc2:DatePicker ID="ctrlStartDatePicker" runat="server" />
                        </td>
                        <td class="adminTitle">
                            <uc1:ToolTipLabelControl ID="lblEndDate" runat="server" Text="<%$ PayrollResources:Admin.Orders.EndDate.Text %>"
                                ToolTip="<%$ PayrollResources:Admin.Orders.EndDate.ToolTip %>" ToolTipImage="~/Administration/Common/ico-help.gif" />
                        </td>
                        <td class="adminData">
                            <uc2:DatePicker ID="ctrlEndDatePicker" runat="server" />
                        </td>
                        <td class="adminTitle">
                            <uc1:ToolTipLabelControl ID="ToolTipLabelControl1" runat="server" Text="<%$ PayrollResources:Admin.Orders.Distributor.Text %>"
                                ToolTip="<%$ PayrollResources:Admin.Orders.Distributor.ToolTip %>" ToolTipImage="~/Administration/Common/ico-help.gif" />
                        </td>
                        <td class="adminData">
                            <asp:TextBox ID="txtDistributor" CssClass="adminInput" runat="server"></asp:TextBox>
                        </td>
                        <td class="adminTitle"></td>
                        <td class="adminData">
                            <a id="aCleare" href="javascript:ClearText()">Xóa Tìm Kiếm</a>
                        </td>
                    </tr>
                </table>
            </div>
            <p></p>
            <asp:GridView ID="gvOrders" runat="server" AutoGenerateColumns="False" Width="100%" DataKeyNames="OrderID"
                OnPageIndexChanging="gvOrders_PageIndexChanging" AllowPaging="True" PageSize="15">
                <Columns>
                    <asp:TemplateField>
                        <HeaderTemplate>
                            <asp:CheckBox ID="cbSelectAll" runat="server" CssClass="cbHeader" />
                        </HeaderTemplate>
                        <ItemTemplate>
                            <asp:CheckBox ID="cbOrder" runat="server" CssClass="cbRowItem" ToolTip="<% $PayrollResources:Admin.Customers.CustName.ToolTip %>" />
                            <asp:HiddenField ID="hfOrderID" runat="server" Value='<%# Eval("OrderID") %>' />
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" Width="0.5%" />
                    </asp:TemplateField>
                    <asp:TemplateField  HeaderText="Số hóa đơn">
                        <ItemTemplate>
                            <asp:HyperLink ID="ActionHyperLink" runat="server" ToolTip="Click vào mã để xem chi tiết" Text='<%# Eval("OrderID") %>' NavigateUrl='<%# String.Format("../OrderAdd.aspx?OrderID={0}", Eval("OrderID")) %>' />                            
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" Width="4%"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Ghi chú">
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Eval("Note") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle Width="10%"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Ngày nhập">
                        <ItemTemplate>
                            <%#DateTimeHelper.ConvertToUserTime((DateTime)Eval("Transdate"), DateTimeKind.Utc).ToString()%>
                        </ItemTemplate>
                        <ItemStyle Width="10%"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Ngày tạo">
                        <ItemTemplate>
                            <%#DateTimeHelper.ConvertToUserTime((DateTime)Eval("CreateDate"), DateTimeKind.Utc).ToString()%>
                        </ItemTemplate>
                        <ItemStyle Width="10%"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Người nhập">
                        <ItemTemplate>
                            <%#Server.HtmlEncode(Eval("CreatebyName").ToString())%>
                        </ItemTemplate>
                        <ItemStyle Width="10%"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Người sửa">
                        <ItemTemplate>
                            <%#Server.HtmlEncode(Eval("ModifiedName").ToString())%>
                        </ItemTemplate>
                        <ItemStyle Width="10%"></ItemStyle>
                    </asp:TemplateField>
                </Columns>

                <PagerSettings PageButtonCount="50" Position="TopAndBottom" />
            </asp:GridView>
            <br />
            <asp:Label runat="server" ID="lblNoOrdersFound" Text="<%$ PayrollResources:Admin.Orders.NoOrdersFound %>"
                Visible="False"></asp:Label>
        </ContentTemplate>
    </ajaxToolkit:TabPanel>
    <ajaxToolkit:TabPanel runat="server" ID="pnlOrderBillingInfo" HeaderText="<% $PayrollResources:Admin.Order.WareHouseInfo %>">
        <ContentTemplate>
            <div class="section-header">
                <div class="title">
                    <img src="Common/ico-sales.png" alt="Quản lý nhập xuất thiết bị" />
                    Quản lý nhập xuất thiết bị
                </div>
                <div class="options">
                    <asp:Button ID="FilterButton" runat="server" Text="<%$ PayrollResources:Admin.Orders.SearchButton %>"
                        CssClass="adminButtonBlue" OnClick="FilterButton_Click" ToolTip="<%$ PayrollResources:Admin.Orders.SearchButton.Tooltip %>" />                  
                    <asp:Button ID="ExportButton" runat="server" Text="Export"
                        CssClass="adminButtonBlue" OnClick="ExportButton_Click" ToolTip="Export to excel" /> 
                </div>
            </div>
            <div style="border: 1px solid #2F00FF; border-radius: 15px;">
                <table class="adminContent">
                    <tr>
                        <td class="adminTitle">
                            <uc1:ToolTipLabelControl ID="ToolTipLabelControl2" runat="server" Text="Đến ngày"
                                ToolTip="Đến ngày" ToolTipImage="~/Administration/Common/ico-help.gif" />
                        </td>
                        <td class="adminData">
                            <uc2:DatePicker ID="dpToDate" CssClass="adminInput" runat="server" />
                        </td>                        
                        <td class="adminTitle">
                            <uc1:ToolTipLabelControl ID="ToolTipLabelControl4" runat="server" Text="<%$ PayrollResources:Admin.Orders.Distributor.Text %>"
                                ToolTip="<%$ PayrollResources:Admin.Orders.Distributor.ToolTip %>" ToolTipImage="~/Administration/Common/ico-help.gif" />
                        </td>
                        <td class="adminData">
                            <asp:TextBox ID="txtCustomerName" CssClass="adminInput" runat="server"></asp:TextBox>
                        </td>
                        <td class="adminTitle"></td>
                        <td class="adminData">
                            <a id="a1" href="javascript:ClearTextWarehouse()">Xóa Tìm Kiếm</a>
                        </td>
                        <td class="adminTitle"></td>
                        <td class="adminData"></td>
                        <td class="adminTitle"></td>
                        <td class="adminData"></td>
                        <td class="adminTitle"></td>
                        <td class="adminData"></td>
                    </tr>
                </table>
            </div>
            <p></p>
            <asp:GridView ID="gvInputOut" runat="server" AutoGenerateColumns="False" Width="100%" DataKeyNames="CustomerID"
                OnPageIndexChanging="gvInputOut_PageIndexChanging" AllowPaging="True" PageSize="15" OnRowDataBound="gvInputOut_RowDataBound">
                <Columns>                    
                    <asp:TemplateField  HeaderText="Tên nhà phân phối">
                        <ItemTemplate>
                            <asp:Label ID="lblCustName" runat="server" Text='<%# Eval("CustName") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Left" Width="10%"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Email">
                        <ItemTemplate>
                            <asp:Label ID="lblCustEmail" runat="server" Text='<%# Eval("CustEmail") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle Width="10%"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Điện thoại">
                        <ItemTemplate>
                            <asp:Label ID="lblCustMobile" runat="server" Text='<%# Eval("CustMobile") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle Width="10%"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Mã số thuế">
                        <ItemTemplate>
                            <asp:Label ID="lblCustTaxCode" runat="server" Text='<%# Eval("CustTaxCode") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle Width="10%"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Tồn đầu">
                        <ItemTemplate>
                            <asp:Label ID="lblCol1" runat="server" Text='<%# Eval("Col1") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" Width="4%"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Nhập">
                        <ItemTemplate>
                            <asp:Label ID="lblCol2" runat="server" Text='<%# Eval("Col2") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" Width="4%"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Xuất">
                        <ItemTemplate>
                            <asp:Label ID="lblCol3" runat="server" Text='<%# Eval("Col3") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" Width="4%"></ItemStyle>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Tồn cuối">
                        <ItemTemplate>
                            <asp:Label ID="lblCol4" runat="server" ></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" Width="4%"></ItemStyle>
                    </asp:TemplateField>
                </Columns>
                <PagerSettings PageButtonCount="50" Position="TopAndBottom" />
            </asp:GridView>
        </ContentTemplate>
    </ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>